package com.zone.gateway.center.interfaces;

import com.zone.gateway.center.domain.message.model.entity.RedisMessageDataEntity;
import com.zone.gateway.common.response.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zongzi
 * @description: TODO
 * @date: 2025/5/7
 */
@RestController
@RequestMapping("/redis/message")
public class RedisMessageController {
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @PostMapping("/publish")
    public Result<Boolean> publishMessage(@RequestBody RedisMessageDataEntity message) {
        redisTemplate.convertAndSend(message.getChannel(), message.getMessage());
        return Result.success(true);
    }
}
